/**
 * 
 */

package com.wutianyi.taskqueue.queue.impl;

import java.util.Collection;
import java.util.List;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;

import com.wutianyi.taskqueue.queue.Task;
import com.wutianyi.taskqueue.queue.TaskQueue;

/**
 * @author wutianyi
 * 
 */
public class Segment<T extends Task> implements TaskQueue<T> {

	BlockingQueue	queue;

	public Segment() {

		queue = new LinkedBlockingQueue();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.wutianyi.queue.TaskQueue#drainTo(java.util.Collection, int)
	 */
	@Override
	public int drainTo(Collection<T> c, int size) {

		if(null == c) {
			return 0;
		}

		return queue.drainTo(c, size);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.wutianyi.queue.TaskQueue#offer(java.lang.Object)
	 */
	@Override
	public boolean offer(T t) {

		return queue.offer(t);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.wutianyi.queue.TaskQueue#pool()
	 */
	@Override
	public T poll(int hideTime) {

		return (T)queue.poll();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.wutianyi.queue.TaskQueue#size()
	 */
	@Override
	public int size() {

		return queue.size();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.wutianyi.queue.TaskQueue#drainTo(int)
	 */
	@Override
	public List<T> drainTo(int size, int hideTime) {

		// TODO Auto-generated method stub
		return null;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.wutianyi.queue.TaskQueue#batchAddTask(java.util.List)
	 */
	@Override
	public void batchAddTask(List<T> tasks) {

		// TODO Auto-generated method stub

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.duowan.zone.taskqueue.queue.TaskQueue#removeTask(java.lang.String)
	 */
	@Override
	public boolean removeTask(T t) {

		return true;
	}

}
